package com.ruoyi.supplier.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.supplier.mapper.TbPurchaseDetailMapper;
import com.ruoyi.supplier.domain.TbPurchaseDetail;
import com.ruoyi.supplier.service.ITbPurchaseDetailService;

/**
 * 采购明细Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-03-05
 */
@Service
public class TbPurchaseDetailServiceImpl implements ITbPurchaseDetailService 
{
    @Autowired
    private TbPurchaseDetailMapper tbPurchaseDetailMapper;

    /**
     * 查询采购明细
     * 
     * @param id 采购明细ID
     * @return 采购明细
     */
    @Override
    public TbPurchaseDetail selectTbPurchaseDetailById(Long id)
    {
        return tbPurchaseDetailMapper.selectTbPurchaseDetailById(id);
    }

    /**
     * 查询采购明细列表
     * 
     * @param tbPurchaseDetail 采购明细
     * @return 采购明细
     */
    @Override
    public List<TbPurchaseDetail> selectTbPurchaseDetailList(TbPurchaseDetail tbPurchaseDetail)
    {
        return tbPurchaseDetailMapper.selectTbPurchaseDetailList(tbPurchaseDetail);
    }

    /**
     * 新增采购明细
     * 
     * @param tbPurchaseDetail 采购明细
     * @return 结果
     */
    @Override
    public int insertTbPurchaseDetail(TbPurchaseDetail tbPurchaseDetail)
    {
        tbPurchaseDetail.setCreateTime(DateUtils.getNowDate());
        tbPurchaseDetail.setCreateBy(SecurityUtils.getUsername());
        return tbPurchaseDetailMapper.insertTbPurchaseDetail(tbPurchaseDetail);
    }

    /**
     * 修改采购明细
     * 
     * @param tbPurchaseDetail 采购明细
     * @return 结果
     */
    @Override
    public int updateTbPurchaseDetail(TbPurchaseDetail tbPurchaseDetail)
    {
        tbPurchaseDetail.setUpdateTime(DateUtils.getNowDate());
        tbPurchaseDetail.setUpdateBy(SecurityUtils.getUsername());
        return tbPurchaseDetailMapper.updateTbPurchaseDetail(tbPurchaseDetail);
    }

    /**
     * 批量删除采购明细
     * 
     * @param ids 需要删除的采购明细ID
     * @return 结果
     */
    @Override
    public int deleteTbPurchaseDetailByIds(Long[] ids)
    {
        return tbPurchaseDetailMapper.deleteTbPurchaseDetailByIds(ids);
    }

    /**
     * 删除采购明细信息
     * 
     * @param id 采购明细ID
     * @return 结果
     */
    @Override
    public int deleteTbPurchaseDetailById(Long id)
    {
        return tbPurchaseDetailMapper.deleteTbPurchaseDetailById(id);
    }
}
